import axios from "../utils/http";

const SpaceStore = {
    namespaced:true,
    state: ()=>({
        space_list:[],
        total: 0
    }),
    mutations: {
        SpaceListMutation(state,list){
            state.space_list = list
        },
        SpaceCountMutation(state,total){
            state.total = total
        }
    },
    actions: {
        SpaceListAction(context,pageator = {page:1,page_size:5}){
            var url = "/api/specslist?page="+pageator.page+"&size="+pageator.page_size
            axios.get(url).then(res=>{
                if(res.code === 200){
                    context.commit('SpaceListMutation',res.list) 
                }
            })
        },
        SpaceCountAction(context){
            var url = "/api/specscount"
            axios.get(url).then(res=>{
                context.commit("SpaceCountMutation",res.list[0].total)
            })
        }
    }
}

export default SpaceStore